import 'package:boss/models/commission.dart';

import 'package:boss/ui/page/commission/page/commissionDetail/commission_detail_page.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/title_row_button.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:router/annotation.dart';

@RouterConfig(CommissionModePage.pageName)
class CommissionModePage extends StatefulWidget {
  static const pageName = '/commissionModePage';

  @override
  _CommissionModePageState createState() => _CommissionModePageState('提成模式');
}

class _CommissionModePageState extends BaseState<CommissionModePage> {
  _CommissionModePageState(String pageName) : super(pageName);

  final List<Map<String, String>> routers = [
    {'name': '菜品提成', 'commissionType': Commission.COMMODITY, 'commissionWay': Commission.ORI_PRICE_PERCENT},
    {'name': '预定提成', 'commissionType': Commission.BOOK, 'commissionWay': Commission.TABLE_NUM},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(title: '提成类型'),
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 25.w),
        child: Column(
          children: <Widget>[
            for (final item in routers)
              TitleRowButton(
                title: item['name'],
                hintText: '',
                onTap: () {
                  Navigator.popAndPushNamed(context, CommissionDetailPage.pageName, arguments: {
                    'commission': Commission.fromJson({
                      'commissionType': item['commissionType'],
                      'commissionWay': item['commissionWay'],
                    }),
                  });
                },
              ),
          ],
        ),
      ),
    );
  }
}
